package com.bibrApp.difu.fragment.wallet_mvp;

import android.content.Intent;
import android.text.TextUtils;
import android.widget.TextView;

import com.bibrApp.difu.DfApp;
import com.bibrApp.difu.R;
import com.bibrApp.difu.actvity.chengjiao_mvp.ChengjiaoActivity;
import com.bibrApp.difu.actvity.my_mvp.MyActivity;
import com.bibrApp.difu.actvity.others.HelpActivity;
import com.bibrApp.difu.actvity.record_mvp.RecordActivity;
import com.bibrApp.difu.actvity.wallet_mvp.WalletActivity;
import com.bibrApp.difu.base.BaseFragment;
import com.bibrApp.difu.utils.BigdecimalUtils;
import com.github.siyamed.shapeimageview.RoundedImageView;

import butterknife.BindView;
import butterknife.OnClick;

public class WalletFragment extends BaseFragment<WalletPresenter> implements IWalletView {

    @BindView(R.id.tv_nick)
    TextView tvNick;
    @BindView(R.id.tv_money)
    TextView tvMoney;
    @BindView(R.id.tv_renzhen)
    TextView tvRenzhen;


    @Override
    protected int getLayoutResId() {
        return R.layout.fragment_wallet;
    }

    @Override
    protected void initPresenter() {
        presenter = new WalletPresenter(getContext(), this);
        presenter.init();
    }

    @Override
    public void error(String msg) {

    }

    @Override
    public void successOfGetAllAssets(String money) {
        tvMoney.setText(BigdecimalUtils.format2Str(Double.parseDouble(money), 2));
    }

    @Override
    public void initView() {

        DfApp app = (DfApp) getActivity().getApplication();
        tvNick.setText(TextUtils.isEmpty(app.getNickName()) ? app.getuId() : app.getNickName());
        if (app.getmData() != null && app.getmData().getCenterUserMain().getSeniorCertification() == 3) {
            tvRenzhen.setText("已认证");
        } else {
            tvRenzhen.setText("未认证");
        }
        presenter.queryAllAssets();
    }


    @OnClick(R.id.bt_help)
    public void helpClick() {
        startActivity(new Intent(getContext(), HelpActivity.class));
    }

    @OnClick(R.id.tv_wallet)
    public void walletClick() {
        Intent intent = new Intent(getContext(), WalletActivity.class);
        intent.putExtra("money", tvMoney.getText().toString());
        startActivity(intent);
    }

    @OnClick(R.id.tv_record)
    public void recordClick() {
        startActivity(new Intent(getContext(), RecordActivity.class));
    }

    @OnClick(R.id.tv_chengjiao)
    public void chengjiaoClick() {
        startActivity(new Intent(getContext(), ChengjiaoActivity.class));
    }

    @OnClick(R.id.iv_avater)
    public void clickAvater(){
        startActivity(MyActivity.class);
    }
}
